package com.link.base.base.order.service;

import com.link.base.base.order.model.ArrivalDetails;
import com.link.base.base.order.model.SaleOrderItem;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.BasicServiceException;

import java.util.List;

/**
 * @author yrf
 * @date unknown
 * @comments 订单行服务
 */
public interface SaleOrderItemService extends BasicService<SaleOrderItem> {


    /**
     * 根据订单Id，查询订单行信息
     *
     * @param orderId 订单id
     * @return 订单行列表
     * @throws Exception
     */
    public List<SaleOrderItem> querylistByOrderId(Long orderId) throws Exception;

    /**
     * 根据订单Id，订单行类型查询行信息
     *
     * @param orderId 订单id
     * @param type 类型
     * @return 订单行列表
     * @throws Exception
     */
    List<SaleOrderItem> querylistByOrderId(Long orderId, String type) throws Exception;

    /**
     * 更新订单行上的数量
     * @param record 订单行
     * @throws BasicServiceException
     */
    public void qtyUpdate(SaleOrderItem record) throws BasicServiceException;

    /**
     * <p>dms新建订单行，根据经销商，产品计算产品价格并插入订单行</p>
     *
     * @author yrf
     * @param orgId 组织id
     * @param acctId 经销商id
     * @param headId 订单头id
     * @param list   需要插入的订单行列表
     * @throws Exception
     */
    public void insertDmsOrderItem(Long orgId, Long acctId, Long headId, List<SaleOrderItem> list) throws Exception;

    /**
     * <p>dms更新修改订单行，根据经销商，产品计算产品价格并插入或更新订单行，已有行不会重新获取价格</p>
     *
     * @author yrf
     * @param acctId
     * @param headId
     * @param list
     * @throws Exception
     */
    public void updateDmsOrderItem(Long acctId, Long headId, List<SaleOrderItem> list) throws Exception;

    /**
     * <p>根据订单头复制订单行信息，原原本本复制</p>
     *
     * @author yrf
     * @param sourceOrderId
     * @param targetOrderId
     * @throws Exception
     */
    public void deepCopyOrderItem(Long sourceOrderId, Long targetOrderId) throws Exception;

    /**
     * 删除订单行信息
     *
     * @param itemExample
     * @throws Exception
     */
    public void deleteByOrderRuleProdId(SaleOrderItem itemExample) throws Exception;

    /**
     * <p>插入促销订单行</p>
     *
     * @author yrf
     * @param list
     * @throws Exception
     */
    public void insertPcyOrderItem(List<SaleOrderItem> list) throws Exception;


    /**
     * 订单商品加
     *
     * @param entity 商品订单行
     * @return
     */
    public void prodCumulateSaleAdd(SaleOrderItem entity);

    /**
     * 订单商品减
     *
     * @param entity 商品订单行
     * @return
     */
    public void prodCumulateSaleSub(SaleOrderItem entity);

    /**
     * 商品累计
     *
     * @param saleOrderItem 商品订单行
     */
    public void prodCumulateSale(SaleOrderItem saleOrderItem);

    /***
     * 获取到货列表
     * @param arrivalDetails
     * @return 到货列表
     * @throws Exception
     */
    public List<ArrivalDetails> queryArriDetailsByPage(ArrivalDetails arrivalDetails) throws Exception;

    /**
     * 查询当前登录导购某天产品销售情况
     *
     * @author Lizt
     * @param saleOrderItem 订单行
     * @return 订单行列表
     * @throws Exception
     */
    public List<SaleOrderItem> querySaleProduct(SaleOrderItem saleOrderItem) throws Exception;
}
